﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;
using StockholmsStad.Web.UI.Class.Interfaces;
using StockholmsStad.Web.UI.Class.Model;
using StockholmsStad.Web.UI.Class.Utilities;
using StockholmsStad.Web.UI.UIServiceReference;

namespace StockholmsStad.Web.UI.Test
{
    /// <summary>
    ///This is a test class for ModelBaseTest and is intended
    ///to contain all ModelBaseTest Unit Tests
    ///</summary>
    [TestClass]
    public class ModelBaseTest
    {
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        #region Additional test attributes

        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //

        #endregion

        /// <summary>
        ///A test for ModelBase Constructor
        ///</summary>
        [TestMethod]
        public void ModelBaseConstructorTest()
        {
            ISession session = new DictionarySessionAdapter(new Dictionary<string, object>());
            MockRepository repository = new MockRepository();
            repository.ReplayAll();
            var target = new ModelBase(session);
            Assert.IsNotNull(target);
            repository.VerifyAll();
        }


        /// <summary>
        ///A test for RegistrationTicketId
        ///</summary>
        [TestMethod()]
        public void RegistrationTicketIdTest()
        {
            ISession session = new DictionarySessionAdapter(new Dictionary<string, object>());
            ModelBase target = new ModelBase(session);
            int? expected = 42;
            int? actual;
            target.RegistrationTicketId = expected;
            actual = target.RegistrationTicketId;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for RegistrationTicketId
        ///</summary>
        [TestMethod()]
        public void RegistrationTicketIdTest2()
        {
            ISession session = new DictionarySessionAdapter(new Dictionary<string, object>());
            ModelBase target = new ModelBase(session);
            int? expected = null;
            int? actual;
            target.RegistrationTicketId = expected;
            actual = target.RegistrationTicketId;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Couple
        ///</summary>
        [TestMethod()]
        public void CoupleTest()
        {
            ISession session = new DictionarySessionAdapter(new Dictionary<string, object>());
            ModelBase target = new ModelBase(session);
            Couple expected = new Couple {CoupleId = 42};
            Couple actual;
            target.Couple = expected;
            actual = target.Couple;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Ceremony
        ///</summary>
        [TestMethod()]
        public void CeremonyTest()
        {
            ISession session = new DictionarySessionAdapter(new Dictionary<string, object>());
            ModelBase target = new ModelBase(session);
            Ceremony expected = new Ceremony {CeremonyLanguage = "Finska"};
            Ceremony actual;
            target.Ceremony = expected;
            actual = target.Ceremony;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for CachedFreeTimeblocks
        ///</summary>
        [TestMethod()]
        public void CachedFreeTimeblocksTest()
        {
            ISession session = new DictionarySessionAdapter(new Dictionary<string, object>());
            ModelBase target = new ModelBase(session);
            IOrderedEnumerable<DateTime> expected = new List<DateTime>
                                                        {
                                                            new DateTime(2008, 01, 01),
                                                            new DateTime(2008, 03, 01),
                                                            new DateTime(2008, 02, 01),
                                                            new DateTime(2008, 04, 01),
                                                        }.OrderBy(d => d.Ticks);
            IOrderedEnumerable<DateTime> actual;
            target.CachedFreeTimeblocks = expected;
            actual = target.CachedFreeTimeblocks;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for CachedBookedTimeblocks
        ///</summary>
        [TestMethod()]
        public void CachedBookedTimeblocksTest()
        {
            ISession session = new DictionarySessionAdapter(new Dictionary<string, object>());
            ModelBase target = new ModelBase(session);
            IOrderedEnumerable<DateTime> expected = new List<DateTime>
                                                        {
                                                            new DateTime(2008, 01, 01),
                                                            new DateTime(2008, 03, 01),
                                                            new DateTime(2008, 02, 01),
                                                            new DateTime(2008, 04, 01),
                                                        }.OrderBy(d => d.Ticks);
            IOrderedEnumerable<DateTime> actual;
            target.CachedBookedTimeblocks = expected;
            actual = target.CachedBookedTimeblocks;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Booking
        ///</summary>
        [TestMethod()]
        public void BookingTest()
        {
            ISession session = new DictionarySessionAdapter(new Dictionary<string, object>());
            ModelBase target = new ModelBase(session);
            Booking expected = new Booking {BookingCode = "pelle"};
            Booking actual;
            target.Booking = expected;
            actual = target.Booking;
            Assert.AreEqual(expected, actual);
        }
    }
}